package com.sbj.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.convert.Convert;
import cn.zhxu.bs.BeanSearcher;
import cn.zhxu.bs.operator.Equal;
import cn.zhxu.bs.util.MapUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sbj.dto.req.ExpendReq;
import com.sbj.dto.res.ExpendRes;
import com.sbj.dto.res.IncomeRes;
import com.sbj.entity.Expend;
import com.sbj.mapper.ExpendMapper;
import com.sbj.service.IExpendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author summer
 * @since 2024/08/10 10:02:40
 */
@Service
@Transactional(rollbackFor = Exception.class)
@AllArgsConstructor
public class ExpendServiceImpl extends ServiceImpl<ExpendMapper, Expend> implements IExpendService {

    private final BeanSearcher beanSearcher;

    @Override
    public List<ExpendRes> lists(ExpendReq req) {
        Map<String, Object> build = MapUtils.builder().field(ExpendRes::getType, req.getType()).op(Equal.class).field(ExpendRes::getMemberId, StpUtil.getLoginId()).op(Equal.class).build();
        return beanSearcher.searchList(ExpendRes.class, build);
    }
}
